<?php
/*    require ( 'init.inc.php' );
    require ( 'checkadmin.inc.php');
    require ( __COMM_PATH . 'pagecontrol.inc.php' );
    require ( __CLASS_PATH . 'page_edit.class.php' );
	
	// -------------------------------------------------------
    // 接收变量
    // -------------------------------------------------------
    $id=$_REQUEST['id'];
	$action=$_REQUEST['action'];
	
	// -------------------------------------------------------
    // 读数据与生成数据
    // -------------------------------------------------------
	$inno="IN_".time().rand(1,100);
	$intime=date("d-m-Y",time());
    $result=$db->query("select * from `website_order` where `id`='$id'");
	 $row=$db->fetch_array($result);
	 
	 
	// -------------------------------------------------------
    // 邮件信息
    // -------------------------------------------------------
	$to  = "$row[useremail]" . ", "; // note the comma
	$to .= "$row[useremail]";

	// 邮件标题
	$subject = 'Invoice (发票)';

   //邮件内容
$message = <<< test
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>恆愛策劃有限公司（发票）</title>
</head>

<body bgcolor="FEF8F9">
 <p align="center" style="color:#FCC; font-size:20px;"><strong>恆愛策劃有限公司（KOEL）</strong></p>
<table  align="center" width="806" bgcolor="#F8D0D8">
    <tr height="30" bgcolor="#E6426B"><td colspan="2" align="center"><strong>Official Receipt （发票）</strong></td></tr>
    <tr><td colspan="2" bgcolor="#F6AEC0">DEAR ：$row[username] <br />
    Thank you for your recent payment which has been processed by our account department.<br />
    <strong>Here is your payment receipt information.</strong>
    </td></tr>
    <tr><td colspan="2">
        <table align="center" width="800" bgcolor="white">
        	<tr><td colspan="2">Name：&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;$row[username]</td></tr>
            <tr><td colspan="2">INVOICE  NUMBER：&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;$inno</td></tr>
            <tr><td colspan="2">INVOICE  DATE：&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;$intime</td></tr>
            <tr><td>
                <table border="1" width="600" style="border-collapse:collapse; border:1px solid #EAEAE2;">
                <tr><td>Description:</td><td>Amount:</td></tr>
                <tr height="60"><td>我们为你的策划的方案实际费用</td><td>$row[trueprice]</td></tr>
                <tr><td>INVOICE  TOTAL  AMOUNT</td><td>RMB：$row[trueprice]</td></tr>
                </table>
           </td></tr>
          <tr><td colspan="2">DATE OF PAYMENT：&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;$intime</td></tr>
          <tr><td colspan="2">TRANSACTION ID / CHEQUE NO.：&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;000009385766</td></tr>
          <tr><td colspan="2">KOEL-Touch your heart ！ <a href="http://www.MyKOEL.com">http://www.MyKOEL.com</a></td></tr>
          <tr><td colspan="2" style="color:red; font-size:12px;">提示: 此信是系统自动发出, 请不要直接"回复"本邮件,谢谢!</td></tr>
        </table>
   </td></tr>
   <tr><td colspan="2" align="center">如果您有任何疑问，欢迎您<a href="http://www.MyKOEL.com">随时联系恒爱(KOEL)客服！</a><br /> 

全國熱線     400-660-6500<br />
&nbsp;&nbsp;澳門熱線 (853) 82946882<br />
</td></tr>
</table>
</body>
</html>
test;

	//邮件头信息
	$headers  = 'MIME-Version: 1.0' . "\r\n";
	$headers .= 'Content-type: text/html; charset=iso-8859-1' . "\r\n";

	// Additional headers
	$headers .= 'To: Mary <xiaozhuge0825@e163.com>, Kelly <xiaozhuge0825@e163.com>' . "\r\n";
	$headers .= 'From: Birthday Reminder <birthday@example.com>' . "\r\n";
	$headers .= 'Cc: birthdayarchive@example.com' . "\r\n";
	$headers .= 'Bcc: birthdaycheck@example.com' . "\r\n";

	// -------------------------------------------------------
    // 发送邮件
    // -------------------------------------------------------
  
	mail("xiaozhuge0825@163.com", $subject, $message, $headers);
	
	// -------------------------------------------------------
    // 把邮件的信息插入数据库
    // -------------------------------------------------------
	$db->query("insert into `website_invoice` (`ordernum`,`invoicenum`,`content`,`sendtime`,`senduser`,`type`) values ('$row[ordernum]','$inno','$message','$intime','$_SESSION[AdminUser]','1')");
	
	// -------------------------------------------------------
    // 记录用户操作
    // -------------------------------------------------------
	file_log($_SESSION['AdminUser'],"生成实际费用的发票");
	echo "<script type='text/javascript'>window.location.href='order_list.php'; alert('成功');</script>"*/
	
	
	
	
	require ( 'init.inc.php' );
    require ( 'checkadmin.inc.php');
    require ( __COMM_PATH . 'pagecontrol.inc.php' );
    require ( __CLASS_PATH . 'page_edit.class.php' );
	//require ( __CLASS_PATH . 'class.phpmailer.php' );
	
	// -------------------------------------------------------
    // 接收变量
    // -------------------------------------------------------
    $id=$_REQUEST['id'];
	$action=$_REQUEST['action'];
	
	// -------------------------------------------------------
    // 读数据与生成数据
    // -------------------------------------------------------
	$inno = "IN_".time().rand(1,100);
	$intime = date("d-m-Y",time());
    $result = $db->query("select * from `website_order` where `id`='$id'");
	$row = $db->fetch_array($result);

   //邮件内容
$message = <<< test
<body bgcolor="FEF8F9">
 <p align="center" style="color:#FCC; font-size:20px;"><strong>恆愛策劃有限公司（KOEL）</strong></p>
<table  align="center" width="806" bgcolor="#F8D0D8">
    <tr height="30" bgcolor="#E6426B"><td colspan="2" align="center"><strong>Official Receipt （发票）</strong></td></tr>
    <tr><td colspan="2" bgcolor="#F6AEC0">DEAR ：$row[username] <br />
    Thank you for your recent payment which has been processed by our account department.<br />
    <strong>Here is your payment receipt information.</strong>
    </td></tr>
    <tr><td colspan="2">
        <table align="center" width="800" bgcolor="white">
        	<tr><td colspan="2">Name：&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;$row[username]</td></tr>
            <tr><td colspan="2">INVOICE  NUMBER：&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;$inno</td></tr>
            <tr><td colspan="2">INVOICE  DATE：&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;$intime</td></tr>
            <tr><td>
                <table border="1" width="600" style="border-collapse:collapse; border:1px solid #EAEAE2;">
                <tr><td>Description:</td><td>Amount:</td></tr>
                <tr height="60"><td>我们为你的策划的方案实际费用</td><td>$row[trueprice]</td></tr>
                <tr><td>INVOICE  TOTAL  AMOUNT</td><td>RMB：$row[trueprice]</td></tr>
                </table>
           </td></tr>
          <tr><td colspan="2">DATE OF PAYMENT：&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;$intime</td></tr>
          <tr><td colspan="2">TRANSACTION ID / CHEQUE NO.：&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;000009385766</td></tr>
          <tr><td colspan="2">KOEL-Touch your heart ！ <a href="http://www.MyKOEL.com">http://www.MyKOEL.com</a></td></tr>
          <tr><td colspan="2" style="color:red; font-size:12px;">提示: 此信是系统自动发出, 请不要直接"回复"本邮件,谢谢!</td></tr>
        </table>
   </td></tr>
   <tr><td colspan="2" align="center">如果您有任何疑问，欢迎您<a href="http://www.MyKOEL.com">随时联系恒爱(KOEL)客服！</a><br /> 

全國熱線     400-660-6500<br />
&nbsp;&nbsp;澳門熱線 (853) 82946882<br />
</td></tr>
</table>
test;

	// -------------------------------------------------------
    // 发送邮件
    // -------------------------------------------------------
		    $emailSubject = "invoice(发票)";
            $sendPort = $site_mail_port;
            $sendHost = $site_mail_smtp;
            $emailName = $site_mail_name;
            $emailPwd = $site_mail_pwd;
            $emailSendFrom = $sitemail;
            $toEmail = $row['useremail'];
            $setssl = $site_mail_ssl==0?false:true;
			sendEmail($emailSubject,$message,$sendPort,$sendHost,$emailName,$emailPwd,$emailSendFrom,$toEmail,$setssl);
	
	// -------------------------------------------------------
    // 把邮件的信息插入数据库
    // -------------------------------------------------------
	$db->query("insert into `website_invoice` (`ordernum`,`invoicenum`,`content`,`sendtime`,`senduser`,`type`) values ('$row[ordernum]','$inno','$message','$intime','$_SESSION[AdminUser]','1')");
	
	// -------------------------------------------------------
    // 记录用户操作
    // -------------------------------------------------------
	file_log($_SESSION['AdminUser'],"生成实际费用的发票");
	echo "<script type='text/javascript'>window.location.href='order_list.php'; alert('成功');</script>"
?> 